import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'
import {resolve} from 'path'
import * as path from "path";

export default defineConfig({
    resolve: {
        extensions: ['.ts', '.js', '.vue', '.json'],
        alias: {
            "@": path.join(__dirname, "./src"), // path记得引入
        }
    },
    plugins: [
        vue(),
        AutoImport({
            resolvers: [ElementPlusResolver()],
        }),
        Components({
            resolvers: [ElementPlusResolver()],
        }),
    ],
    server: {
        hmr: true,
        proxy: {
            // 选项写法
            '^/api': {
                target: 'http://localhost:8080',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '')
            },
            '^/faceapi': {
                target: 'http://127.0.0.1:5000',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/faceapi/, '')
            },
            '^/map': {
                target: 'https://restapi.amap.com',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/map/, '')
            }
        }
    },
    css: {
        // css预处理器
        preprocessorOptions: {
            scss: {
                charset: false,
            },
        },
    }
})



